package com.sct.meiye.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.sct.meiye.entity.IntegralBill;
import com.sct.meiye.entity.Result;
import com.sct.meiye.entity.WalletBill;
import com.sct.meiye.service.IntegralBillService;
import com.sct.meiye.service.WalletBillService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/sct/api/meiye/walletBill")
public class IntegralBillController {

    @Autowired
    private IntegralBillService integralBillService;

    /**
     *  根据用户id, 获取所有 钱包账单记录信息
     * @return
     */
    @GetMapping("/getIntegralBillListByUserId")
    public Result<Object> getIntegralBillListByUserId(
                        @RequestParam(value = "userId", required = false, defaultValue = "0") Long userId){
        return new Result<>(HttpStatus.OK.value(),"success",
                integralBillService.list(new QueryWrapper<IntegralBill>().lambda().eq(IntegralBill::getUserId,userId).orderByDesc(IntegralBill::getDetailTime)));
    }



}
